function firstPageOrder(){
    var form = document.getElementById('form');
    document.getElementById("pageNum").value = "1";
    form.action="/admin/order";
    form.submit();
}
function lastPageOrder(){
    var form = document.getElementById('form');
    document.getElementById("pageNum").value = document.getElementById("totalPages").value;
    console.log( document.getElementById("pageNum").value);
    console.log( document.getElementById("totalPages").value);
    form.action="/admin/order";
    form.submit();
}
function nextPageOrder(){
    var form = document.getElementById('form');
    var totalPages=document.getElementById("totalPages");
    var pageNum=document.getElementById("pageNum");
    pageNum.value=parseInt(pageNum.value)+1;
    if(pageNum.value>=totalPages.value)
        pageNum.value=totalPages.value;
    form.action="/admin/order";
    form.submit();
}
function prePageOrder(){
    var form = document.getElementById('form');
    var pageNum=document.getElementById("pageNum");
    pageNum.value=pageNum.value-1;
    if(pageNum.value<=0)
        pageNum.value=1;
    form.action="/admin/order";
    form.submit();
}
function searchPageOrder(){
    var form = document.getElementById('form');
    var pageNum=document.getElementById("searchPageNum");
    var totalPages=document.getElementById("totalPages").value;
    if (pageNum.value>totalPages)
        pageNum.value=totalPages;
    if(pageNum.value<=0)
        pageNum.value=1;
    document.getElementById("pageNum").value=pageNum.value;
    form.action="/admin/order";
    form.submit();
}
function searchOrder() {
    var searchkeyword=document.getElementById("searchKeyword").value
    console.log(searchkeyword);
    if (searchkeyword !== "") {
        var form = document.getElementById('form');
        document.getElementById("keyword").value = searchkeyword;
        document.getElementById("sort").value = "";
        document.getElementById("status").value = "";
        document.getElementById("pageNum").value = "1";
        form.action="/admin/order"
        form.submit();
    }
}
function searchAccount() {
    var searchkeyword=document.getElementById("searchKeyword").value
    console.log(searchkeyword);
    if (searchkeyword !== "") {
        var form = document.getElementById('form');
        document.getElementById("keyword").value = searchkeyword;
        document.getElementById("sort").value = "";
        document.getElementById("status").value = "";
        document.getElementById("pageNum").value = "1";
        form.action="/admin/account"
        form.submit();
    }
}
function toOrder(obj){
    var form= document.getElementById('form');
    form.action="/admin/order";
    var input = document.createElement("input");
    input.setAttribute("type", 'hidden');
    input.setAttribute("name", 'accountId');
    input.setAttribute("value", obj.id);
    form.appendChild(input);
    console.log(input);
    form.submit();
}
function searchTotalPrice() {
    console.log("1");
    var form = document.getElementById('form');
    console.log("2");
    document.getElementById("sort").value = "totalPrice";
    console.log("3");
    var status = document.getElementById("status");
    console.log("4");
    console.log(status.value);
    console.log(document.getElementById("totalPrice"));
    status.value = document.getElementById("totalPrice").value;
    console.log("5");
    form.action="/admin/order";
    form.submit();
}

function searchMetaOrder() {
    var form = document.getElementById('form');
    document.getElementById("sort").value = "meta";
    var status = document.getElementById("status");
    status.value = document.getElementById("meta").value;
    form.action="/admin/order";
    form.submit();
}

function searchGoodNum() {
    var form = document.getElementById('form');
    document.getElementById("sort").value = "goodNum";
    var status = document.getElementById("status");
    status.value = document.getElementById("goodNum").value;
    console.log(status);
    form.action="/admin/order";
    form.submit();
}
function searchDate() {
    var form = document.getElementById('form');
    document.getElementById("sort").value = "date";
    var status = document.getElementById("status");
    status.value = document.getElementById("date").value;
    console.log(status);
    form.action="/admin/order";
    form.submit();
}
function updateOrder(obj){
    var form=document.getElementById("form");
    var input = document.createElement("input");
    input.setAttribute("type",'hidden') ;
    input.setAttribute("name",'orderId') ;
    input.setAttribute("value", obj.id) ;
    form.appendChild(input);
    form.action="/admin/updateOrder"
    form.submit();
}
function toUpdateOrder(obj){
    var form=document.getElementById("form");
    var input = document.createElement("input");
    input.setAttribute("type",'hidden') ;
    input.setAttribute("name",'orderId') ;
    input.setAttribute("value", obj.id) ;
    form.appendChild(input);
    form.action="/admin/toUpdateOrder"
    form.submit();
}